package com.scuec.tourismwebsite.mapper;

import com.scuec.tourismwebsite.entity.City;
import com.scuec.tourismwebsite.entity.WeatherRealTime;
import com.scuec.tourismwebsite.vo.ViewWeatherRealTimeWithCity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeatherRealTimeMapper {

    @Select("select w.weather_id,w.date,w.time,c.city_id,c.city_name,c.province,w.temperature,w.wind_direction," +
            "w.wind_force,w.weather_condition,w.humidity,w.pressure,w.create_date  " +
            "from weather_real_time w join city c on w.city_id = c.city_id order by  c.city_name,w.date, w.time")
    List<ViewWeatherRealTimeWithCity> getWeatherRealTime();


    @Insert("INSERT INTO weather_real_time (weather_id, city_id, date,time,temperature, " +
            "wind_direction, wind_force, weather_condition, " +
            "humidity, pressure, create_date) " +
            "VALUES (#{weather_id}, #{city_id}, #{date},#{time},#{temperature}, " +
            "#{wind_direction}, #{wind_force}, #{weather_condition}, " +
            "#{humidity}, #{pressure}, #{create_date})")
    Integer insertWeatherRealTime(WeatherRealTime weatherRealTime);

    @Update("update weather_real_time set city_id = #{city_id}, " +
            "date = #{date}," +
            "time = #{time}," +
            "temperature = #{temperature}," +
            "wind_direction = #{wind_direction}," +
            "wind_force = #{wind_force}," +
            "weather_condition = #{weather_condition}," +
            "humidity = #{humidity}," +
            "pressure = #{pressure},create_date = #{create_date} " +
            "where weather_id = #{weather_id}")
    Integer updateWeatherRealTime(WeatherRealTime weatherRealTime);

    @Delete("delete from weather_real_time where weather_id = #{weather_id}")
    Integer deleteWeatherRealTime(Integer weather_id);


}
